package com.sabo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class ShowConfigController {

    /**
     * 读取nacos创建的配置,修改后自动刷新
     * DataID=example.yml
     * Group=DEFAULT_GROUP
     * name: pla
     * age: 16
     */

    @Value("${name}")
    private String name;

    @Value("${age}")
    private Integer age;

    @GetMapping("/get/name")
    public String showConfig(){
        return String.format("name=%s age=%s",name,age);
    }

}
